import React from 'react';

import Auditlist from './auditList';
// import { Resource } from '../service/resource';
import LocalStorage from '../service/LocalStorage';
import { NavBar } from 'antd-mobile';
import BrowserUtils from '../service/history';

let tabOptions = {};
export default class Home extends React.Component {
    constructor(props) {
        super(props);
        //  初始定义state 变量
        this.state = {
            title: "待审列表",
            rightLabel: '',
            onRightTouchTap: () => this.messageList(),
            selectedTab: 0,
            hidden: false
        };
        tabOptions = {
          title: "待审列表",
          rightLabel: '',
          onRightTouchTap: () => this.messageList(),
          selectedTab: 0
        }
    }

    componentWillMount() {
      this.isLogin();
    }

    // componentDidMount() {   
    // }

    isLogin() {
      const user = LocalStorage.getItem('user');
      if (!user) {
        BrowserUtils.push({pathname: '/login'});
        return;
      }
    }


    messageList() {
      BrowserUtils.push({pathname: '/messageList'});
      tabOptions.selectedTab = 0;
    }

    render() {
        return (
          <div style={{height: '100vh', display: this.props.display}}>
          <NavBar
            mode="dark"
            className="am-tab-bar-bar"
            style={{top: 0}}
            iconName={false}
            rightContent={[
              <div key="0" onClick={() => tabOptions.onRightTouchTap()}>{tabOptions.rightLabel}</div>
            ]}
          >
          {tabOptions.title}
          </NavBar>
          <Auditlist {...this.props} tag={tabOptions.selectedTab} />
        </div>
        );
    }
}


